<template>
    <div class="addr-add-container">
        <ul class="form">
            <li><input type="text" placeholder="姓名" confirm-type="done" v-model="addrData.consignee"></li>
            <!-- <li><input type="number" placeholder="youzhe" ></li> -->
            <li><input type="text" placeholder="省份" v-model="addrData.province"></li>
            <li><input type="text" placeholder="城市" v-model="addrData.city"></li>
            <li><input type="text" placeholder="地区 " v-model="addrData.district"></li>
            <li><input type="text" placeholder="详细地址 " v-model="addrData.address"></li>
            <li><input type="text" placeholder="邮政编码" v-model="addrData.zipcode"></li>
        </ul>
        <div class="actions">
            <button type="warn" @click="saveAddr">确认修改</button>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return {
            addrData:{
                id:'',
                consignee:'',
                province:'',
                city:'',
                district:'',
                address:'',
                zipcode:''
            }
        }
    },
    methods:{
        saveAddr(){
            this.$http.post({
                url:'m=Index&a=addrEdit',
                data:this.addrData
            }).then(res=>{
                if(res.errcode==0){
                    mpvue.navigateTo({url:'../addr_list/main'});
                }else{
                    wx.showToast({
                        title:'修改失败',
                        icon:'none',
                        duration:500
                    })
                }
            });
        }
    },
    onLoad(params){
        const that=this;
        const id=params.id;
        this.$http.get({
            url:'m=Index&a=getAddrDetail',
            data:{id}
        }).then(res=>{
            that.addrData.id=res.data.id;
            that.addrData.consignee=res.data.consignee;
            that.addrData.province=res.data.province;
            that.addrData.city=res.data.city;
            that.addrData.district=res.data.district;
            that.addrData.address=res.data.address;
            that.addrData.zipcode=res.data.zipcode;
        });
    }
}
</script>
<style lang="scss">
@import './static/styles/reset.scss';
page{
    background-color: $bgColor;
}
.addr-add-container{
    .form{
        background: #FFF;
        input{
            padding: 24rpx 20rpx;
            margin: 20rpx 0;
            border-bottom: 1px solid #CCC;
        }
    }
    .actions{
        position: fixed;
        bottom:10rpx;
        left:0;
        width: 100%;
    }
}
</style>
   
